package com.cloudlinkin.start;

import com.cloudlinkin.entity.HfxContactResult;
import com.cloudlinkin.service.impl.ContactsServiceImpl;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class SmsSendStart implements CommandLineRunner {

	protected final Logger log = Logger.getLogger(this.getClass());


	@Value("${threadUtils.thread_count}")
	private int threadCount;
	@Value("${is_open_multiple_templates}")
	private Boolean is_open_multiple_templates;

	@Autowired
    private ContactsServiceImpl contactsService;

	@Override
	public void run(String... args)  {
//        HfxContactResult result = contactsService.getContactId("123479283", "13934149229");
//        System.out.println(result.getContactId());
		log.info("SmsSendStart run method Started !!");


		// 开始启动消费短信队列

		// 将配置传入service   启动不同的线程开始下发
//
//		try {
//
//			for (Province province : CacheProvinces.province) {
//				log.error(province.toString());
//
//
//				for (int i = 0; i < province.getThreadCount(); i++) {
//					HfxSmsServiceImpl hfxSmsServiceImpl = ApplicationContextProvider.getBean(HfxSmsServiceImpl.class);
//					hfxSmsServiceImpl.setHfxQueueName(province.getQueueName());
//					ThreadUtils.runTask(hfxSmsServiceImpl);
//				}
//			}
//
//			log.info("SendServerStartUp is OK!");
//		} catch (Exception e) {
//			e.printStackTrace();
//			log.error(e);
//			System.exit(0);
//		}

		//测试代码

		// 获取用户的联系人ID
		HfxContactResult result = contactsService.getContactId("123169913", "15011307212");
		System.out.println(result.getContactId());
		// yxd 704666176
		// 13802883512 704666367
		// 704666748
		// gyf 15011307212
	}
}